Name of the movie, please help

Movie from late 50’s or 60’s man is poor and walking next to a horse and when he wants eating from a basket of a horse he is getting caught by guards/police.

Poor man went to prison, the guards finding a proof of letter that he is a king.

But he is not a king he previously teared a letter without his name from a king.

Musical or movie, commedy

a long shot, some adaptation of “prisoner of zenda”?

It’s a commedy (musical) movie, the actor looks a bit of Gene Wilder

This perhaps?