There are two types of songs. Whenever anyone begins an explanation with this kind of classification what they are about to describe are two opposite ends of a spectrum with many shades in between. A few extremes set the definitions on either end but most fall in the middle.
That said, I can hear, and divide, songs into two categories: lyric driven and music driven. For extremes we have something like "thinking out loud" on one end where the words carry every beat and set the melody. There is some light guitar behind the vocals mostly holding a rhythm, but very little music overall. It's nearly a cappella. Perhaps he wrote the rhythm first, a general groove and then penned lyrics to it. More likely, Sheeran heard this melody in his head, at least the pre-chorus to the chorus, and it was probably stuck in his head for a while as he developed the just the words for just the right spots.
The other end could be something from Phish, who is known for jamming and musicianship, with lyrical content coming second, or even later. Fans are not there to celebrate content, but to listen to all the cool sounds working together and driving them to shuffle, two-step or boogie down. I imagine the entire band in a room jamming away, or someone bringing a particular lick or a groove and them working some parts that fit and smoothing that into a song. Lyrics are then written later according to how the song makes Trey feel, what he hears it saying to him.
Neither way is correct. Some come to music for lyrics, like me, supported by quality music underneath. Others couldn't care less what is being said or what the meaning of a song is. They can feel the mood and ascertain some emotion from sound alone.
For me, the best is a balance between the two. I want my songs to be enjoyable to even people who don't understand English. So if you don't speak the language at all, the rhythm and melody is still interesting, still evokes emotion. Some songs are more successful than others. Sometimes you have a lot of lyrics, or a heavy theme that needs some isolation and shouldn't be overwhelmed by a lot of chord changes or instrumentation. Other times you have just a fun song that should feature more the music and less on deep meaning or complicated lines. Paul Simon described it as knowing when to be sophisticated with your writing and when not to. This is part of the balance that makes great things great.