Do you have to be proficient in martial weapons to use a martial weapon for example?
So, why care about using a weapon with which you're proficient?
You add your proficiency bonus to your attack roll when you attack using a weapon with which you have proficiency.... (PHB p.194, "Attack Rolls")
See also pp.12 and 14 ("Building Bruenor") and p.146 ("Weapon Proficiency").
So you can certainly attack using a weapon with which you're not proficient: you're just rather less-likely to hit when you do than if you'd used a weapon with which you are proficient.