That information is not needed. It's not illegal to ask for it, but there is no legal reason to do so either. I have never had anybody outside government authorities and banks that give loans ask for a payslip in Germany.
What they do need is your social security number, your health insurance number and your tax id. That is a legal requirement because they are legally required to pay into those funds on your behalf. They also need your bank account to pay you. They may also need additional information like drivers license if you have access to company's cars or "Polizeiliches Führungszeugnis" (criminal record check) if you are working with minors. Employers do not need to know what you were or still are paid outside of their employment.
Maybe you misunderstood them and they didn't actually ask for a payslip, but for this information? Maybe they thought it would be easier on both you and them to ask for a payslip because it already contains the information they need?
You are under no legal obligation to provide your payslip to anybody. Period. Anybody who legally needs it (tax authorities) already got it electronically before you even had it in the mail. Obviously sometimes you want to provide it because you want a service and see their need to see it (loan application for example) and I guess sometimes you get asked without seeing the need. Never happened to me but you seem to have found such a rare case.
You should ask them what exactly they need from the payslip and if they say "the whole payslip" just act curious and ask them why.