The dust cap helps keep dust/dirt etc. out of the bearings in general, and any excess grease inside the hub/bearings/spindle area and is not strong enough to do anything else. From the pic, it looks like the castle nut is loose even with a cotter pin being used as well.
Suggest you jack up that side, remove the cotter pin/bearings, inspect the bearings/spindle for gouges, rough spots, etc., clean and re-pack the bearings if all looks good, and then snug the bearings down properly. I usually hand tighten the castle nut down, then use some large channel locks, etc., and tighten down some more but not to where the wheel will not spin, then back the nut off so the wheel spins freely and line up the cotter pin hole with the flanges on the castle nut. Install the cotter pin, and the dust cap. Might as well do both sides while your hands are dirty.