The "à" is a preposition in this sentence (I think) and it is giving direction to where the pain is. The literal translation would go something like "I have bad to the shoulder" which is where the "à" would come in. And to answer your question below about "my," it's not necessary when referring to body parts. I think the way my professor explained it is that the body parts are assumed as belonging to you. Another example of this would be: "Je me brousse les dents" or "I brush my teeth." Hope this helps a little :)
This is where Duolingo messes up a little because they don't really explain it very well. If you're talking about having a pain, it usually means it's "your" body part. So saying "J'ai mal à l'épaule" is saying "I have a pain in my shoulder" which you gather from the context of the situation. It's also an idiomatic expression and nothing ever translates perfectly from language to language, which is why your answer "I have pain in the shoulder" was wrong.
'I have an aching shoulder.' was marked wrong. I think it'd be considered the same as painful or sore.
French people say "j'ai mal à lépaule" and not "j'ai mal à mon épaule" because for us, when you have a pain anywhere,This pain belongs always for yourself ( you can't have a pain for anybidy elsr!). We use the logical.this explanation. We teach our children to learn french langage.;-)
The possessive adjective is almost never used with body parts - you rarely say things like "my leg" or "his hair." Typically, in French reflexive verbs are used to show possession with body parts.
Je me suis cassé la jambe. - I broke my leg
je suis tombée et je me suis cassé le bras - I fell and broke my arm
Il s'est lavé les cheveux. - He washed his hair
As for why your answer 'I have pain in shoulder was marked wrong is because it is not good English. Typically you would say:
I have a sore shoulder
I have a pain in my shoulder