the matter means wrong in the idiom "for something to be the matter", so the matter acts like an adjective. Idioms often don't make sense when each word is examined separately; they have to be taken as a specific group of words with a meaning that is unexpected for those words. There's something the matter with this pen.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.