My Galaxy S4 with Lollipop sometimes does not accept my unlock pincode
That is a very odd situation.

I'm assuming that you're using the stock lockscreen, not a third party.


My first recommendation is to use a different lockscreen type. If you're using PIN, try a pattern. This is actually going to be the easiest solution.
Install Go Locker or other 3rd party lockscreen, run it once, then immediately uninstall it. Reboot, go into settings, set up your original lockscreen again.
I noticed you're running 5.0.1. Assuming you're all stock and unrooted, accept the OTA update to 5.1.1 and that should solve these weird issues.
If that doesn't work, you may have to stick with Go Locker.