Why does sampling frequency affect the filter results? I have a big issue,  basically my goal is to create a low-pass butterworth filter  around 0-35Hz  with a sampling frequency of 5000Hz.
My Matlab code is

 Fs=5000;
Wp=30/(Fs/2);
Ws=45/(Fs/2);
Rp_db=-20*log10(.95);
Rs_db=-20*log10(.05);
[order,wn] = buttord(Wp,Ws,Rp_db,Rs_db);


But it doesn't work, becouse the filter explodes




As you can see the filter is unstable.But if i change the sampling frequency from 5000Hz to 500Hz things change



with the cutt-off frequency 0.135 (33,75 Hz).

Why does the sampling frequency affect so much the filter result?
Thanks in advance
Limited numerical precision. The higher the sample rate, the closer the poles move to the unit circle, the closer to the unit circle, the less stable the filter is.

There are different implementation methods that are better than others: design as poles, and zeros and not as transfer function, use cascaded second order sections, use correct section ordering, higher precision data types, etc.

In most cases very high order filters with poles close to the unit circle are a bad idea. You get very high group delay and phase distortions and massive time domain ringing.