Have you ever been in Tableau Desktop trying to make a visualisation and thought, "Huh, looks like I have a bunch of fields that should be rows instead. I wish I could just unpivot them quickly in Tableau Desktop, rather than going into Tableau Prep!" (Note: other data preparation tools are available.)
If so, you may be excited to learn that this is in fact possible in Tableau Desktop itself. You can do this simply by selecting the fields you wish to unpivot, right-clicking on your selection and choosing "Pivot". If you then want to undo this, you can then select those fields and choose "Remove Pivot"; if you missed out a field that should have been pivoted, you can right-click it and choose "Add to the Pivot".
But there are a number of reasons you might not want to do it this way. For starters, sometimes you need to pivot (aka rows to columns) rather than unpivot (aka columns to rows). Unfortunately, Tableau Desktop will only let you do the former and not the latter. Depending on what you need to do with your data, an external data preparation tool may be needed.
Another limitation to consider is that Tableau Desktop will only allow you one single unpivot. Sometimes that won't cause a problem. But what if further down the line you need to do another pivot on that same data in the workbook? Unless you're au fait with editing custom SQL queries in Tableau Desktop, this will mean loading your data into a data preparation tool, creating an output and most likely swapping out your data sources within the workbook. At that point, you might as well have done that first pivot in outside of Desktop and saved yourself the hassle.
Finally - and perhaps most crucially - is documentation, which affects the longevity and replicability of your workbook. When you pivot the data in Tableau Desktop, that transformation exists only for that data within that workbook. That means if you load the data in again, you'd have to do that pivot again. Furthermore, it won't be immediately obvious to anyone else you might hand that workbook over to that you've performed a pivot. If they need to recreate your work in another workbook - or even another software - they will have to parse what you did and then apply the same steps. Compare this to the scenario in which you created a simple Tableau Prep workflow to load in your data, unpivot, and then output as a clean file. The workflow itself is documentation of the steps performed to get the output, and any future users (including you) can work directly off that clean file you've created, without having to repeat any steps.
It may not seem like that big a deal, but when the data are complex and people are working under a time pressure, these little things can make a big difference. So next time you need to do a simple pivot and are tempted to do it in Tableau Desktop, first think about best practice and who else might be looking at it!
