Believe it or not, there is a term for this, called edging. There are mixed thoughts on if this is really good for you. Sperm will usually just be reabsorbed into the body, no harm. Here's a full article on it. https://www.healthline.com/health/healthy-sex/is-edging-bad#potential-benefits
GuitarRox is correct that it doesn’t do a lot of harm if you were to do it in once in awhile, but I would strongly recommend NOT doing this on a regular basis. You could be setting yourself up for prostate issues such as Prostatitis, and even worse, prostate cancer down the road. Several studies have shown that frequent ejaculation seems to have a protective effect against developing prostate cancer many years later. Dr’s & scientists are not sure why, but the theory is that ‘flushing’ the fluids out regularly prevents stagnation that can eventually cause changes leading to developement of cancer. So my recommendation would be, if you want to do this once a week or so, it might be OK, but then go ahead & ejaculate 3-4 times a week for maximum health benefits.