If it is red, it likely indicates blood
so what it sounds like is you must have scratched it before, it bled a little and turned into a crust like solid and when you scratched it again, it fell out.
whatever is inside, maybe a pimple from clogged pore usually heals by itself, so avoid disturbing it :)
If you feel pain, discomfort or changes in your hearing, visit your doctor who can have a look inside your ear to see what is going on.
Hope I helped :)